<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>SmartUpload</title>
		<script type="text/javascript" language="javascript">
			window.onload =function(){
				document.getElementById("form").onsubmit = function(){
					var regex = /^\S+$/;
					var form = document.getElementById("form");
					var iderrormsg = document.getElementById("iderrormsg");
					var pic0 = form.pic0.value;
					var pic1 = form.pic1.value;
					var pic2 = form.pic2.value;
					var describe0 = form.describe0.value;
					var describe1 = form.describe1.value;
					var describe2 = form.describe2.value;
					if(!regex.test(pic0)){iderrormsg.textContent="picture1?";return false;}
					if(!regex.test(pic1)){iderrormsg.textContent="picture2?";return false;}
					if(!regex.test(pic2)){iderrormsg.textContent="picture3?";return false;}
					if(!regex.test(describe0)){iderrormsg.textContent="iddescribe1?";return false;}
					if(!regex.test(describe1)){iderrormsg.textContent="iddescribe2?";return false;}
					if(!regex.test(describe2)){iderrormsg.textContent="iddescribe3?";return false;}
					return true;
				};
			};
		</script>
	</head>
	<body>
		<jsp:include page="/jspdemo/header.jsp" />
		<form id="form" action="/test/fileOperateServlet?fileoperate=smartupload" method="post" enctype="multipart/form-data">
			<table>
				<tr><td>1st picture:</td><td><input type="file" name="pic0" /></td></tr>
				<tr><td>describe:</td><td><input type="text" name="describe0" /></td></tr>
				<tr><td>2nd picture:</td><td><input type="file" name="pic1" /></td></tr>
				<tr><td>describe:</td><td><input type="text" name="describe1" /></td></tr>
				<tr><td>3rd picture:</td><td><input type="file" name="pic2" /></td></tr>
				<tr><td>describe:</td><td><input type="text" name="describe2" /></td></tr>
				<tr><td><input type="reset" value="重置"></td><td><input type="submit" value="上传"></td></tr>
			</table>
		</form>
		<label id="iderrormsg" style="color:red">${msg}</label>
		<br>
		<c:forEach items="${pics }" var="pic">
			<img src="userupload/${pic}"/ width="100" height="100"><br>
			<a href="/test/fileOperateServlet?filename=${pic}&fileoperate=smartdownload">Download</a><br>
		</c:forEach>
		<c:forEach items="${describes }" var="d">
			--${d}--
		</c:forEach>
	</body>
</html>